<?php
include 'header.php';
$no_result = false;
?>

<!----------------------------------------FIN de la  partie qui concerne le SLIDER ---------------------------------------->

</div>

</div>

<section>
	<colonne_centre>

		<?php

		include 'forum/connect.php';

		$name;
		if(isset($_GET["name"]))
		{
			$name = $_GET["name"];		
		}	
		else if(isset($_SESSION['user_email'])){ 
			$name = $_SESSION['user_email'];
		}
		else{
			die("you must login to see the content of this page.");
		}

		$sql = "SELECT
		 *
		 FROM
		 users
		 WHERE
		 user_email = '" . mysql_real_escape_string($name) . "'";

		$result = mysql_query($sql);

		if (!$result) {
			//something went wrong, display the error
			echo 'Something went wrong while retrieving in the data. We apologize for that.';
			echo mysql_error();
			//debugging purposes, uncomment when needed
		} else {
			//the query was successfully executed, there are 2 possibilities
			//1. the query returned data, the user can be signed in
			//2. the query returned an empty result set, the credentials were wrong
			if (mysql_num_rows($result) == 0) {
				echo 'This is not a valid account id. Sorry about that.';
				$no_result = true;
			} else {
				//set the $_SESSION['signed_in'] variable to TRUE
				$_SESSION['signed_in'] = true;

				//we also put the user_id and user_email values in the $_SESSION, so we can use it at various pages
				while ($row = mysql_fetch_assoc($result)) {
					$_SESSION['user_id'] = $row['user_id'];
					$_SESSION['user_email'] = $row['user_email'];
					$_SESSION['user_level'] = $row['user_level'];
					$_SESSION['user_firstname'] = $row['user_name'];
					$_SESSION['user_lastname'] = $row['user_lastname'];
					$_SESSION['user_email'] = $row['user_email'];
					$_SESSION['user_function'] = $row['fonction'];
					$_SESSION['user_entreprise'] = $row['entreprise'];
					$_SESSION['user_tel'] = $row['user_tel'];
				}
			}
		}
		?>
	</colonne_centre>
	
	<?php
	if(!$no_result){
	?>
<button onclick="window.location.href='modify_pp.php'">
		Modify public profile
	</button>
	<button>
		Change settings
	</button>

	<p>
		Picture:
	</p>
	<p>
		First Name: <?php echo $_SESSION['user_firstname']
		?>
	</p>
	<p>
		Last Name: <?php echo $_SESSION['user_lastname']
		?>
	</p>
	<p>
		Email: <?php echo $_SESSION['user_email']
		?>
	</p>
	<p>
		Level: <?php echo $_SESSION['user_level']
		?>
	</p>
	<p>
		Function: <?php echo $_SESSION['user_function']
		?>
	</p>
	<p>
		Entreprise:<?php echo $_SESSION['user_entreprise']
		?>
	</p>
	<p>
		Phone:<?php echo $_SESSION['user_tel']
		?>
	</p>
	<p>
		Anne dip:
	</p>
	<?php
} 
?>

</section>
</div>

</div>
</body>
</html>
